import {
  Block,
  View,
  ScrollView,
  OpenData,
  Video,
  Image,
  Text,
  Button
} from '@tarojs/components'
import Taro from '@tarojs/taro'
import withWeapp from '@tarojs/with-weapp'
import { AtList, AtListItem } from "taro-ui";

import Page from '../../component/page';
import './index.scss'
//logs.js
const flow = require('../../utils/flow.js')
const modules = require('./module.js')
const regeneratorRuntime = require('../../utils/async.js')

const LIKE = require("../../icons/like.png")

const app = Taro.getApp()

@withWeapp('Page')
class _C extends Taro.Component {
  state = {
    userInfo: {}
  }
  init = () => {
    const user_name = app.globalData.me && app.globalData.me.user_name || ''

    this.setData({
      user_name,
      statusBarHeight: app.globalData.statusBarHeight,
      userInfo: app.globalData.userInfo
    })
  }
  go2favorite = () => {
    Taro.navigateTo({ url: `../favorite/index` })
  }
  componentWillMount = page => {
    this.flow = new flow(
      this,
      modules
    )
    this.init()
  }
  config = {
    navigationBarTitleText: ''
  }

  render() {
    const {
      user_name: user_name
    } = this.state
    const { headerHeight, contentHeight } = app.globalData

    return (
      <Block>
        <Page title="我的" />
        <ScrollView 
          className="page-container"
          style={`margin-top: ${headerHeight + 10}px;`}
        >
          <View className="me-header">
            <OpenData type="userAvatarUrl" className="me-photo" />
            <View className="me-info">
              <View className="me-name">{user_name}</View>
            </View>
          </View>

          <AtList>
            <AtListItem
              title='喜欢的文章'
              arrow='right'
              onClick={this.go2favorite}
              thumb={LIKE}
            />
          </AtList>
          
        </ScrollView>
      </Block>
    )
  }
}

export default _C
